package com.his.controller;

import com.his.common.core.domain.AjaxResult;
import com.his.entity.dto.MedicalRecord;
import com.his.entity.po.DiseasePO;
import com.his.service.IMedicalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/medical")
public class MedicalController {
    @Autowired
    private IMedicalService medicalService;

    /**
     * 创建病历
     * @param medicalRecord
     * @return
     */
    @PostMapping("/create")
    public AjaxResult create(@RequestBody MedicalRecord medicalRecord) {
        medicalService.create(medicalRecord);
        return AjaxResult.success();
    }

    /**
     * 查询所有疾病信息
     * @return
     */
    @GetMapping("/diagnosis")
    public AjaxResult diagnosis(@RequestParam Long registerId) {
        return AjaxResult.success(medicalService.diagnosis(registerId));
    }

    /**
     * 添加疾病信息
     * @param diseasePO
     * @return
     */
    @PostMapping("/diagnosis")
    public AjaxResult addDisease(@RequestBody DiseasePO diseasePO) {
        medicalService.AddDisease(diseasePO);
        return AjaxResult.success();
    }

    /**
     * 删除疾病信息
     * @param diseaseId
     * @return
     */
    @DeleteMapping("/diagnosis")
    public AjaxResult deleteDisease(@RequestParam Long diseaseId) {
        medicalService.deleteDisease(diseaseId);
        return AjaxResult.success();
    }
}
